package com.zq.controller;

import com.zq.entity.User;
import com.zq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description:
 * @author: ZQ
 * @date: 2021-02-24-10:29
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/hello")
    public String hello(){
        return "hello!";
    }

    @PostMapping("/register")
    public String registerOne(@Validated User user) {
        userService.saveUser(user);
        return "注册成功";
    }

    @PostMapping("/login")
    public String loginByUser(@Validated User user){
        boolean b = userService.loginByUser(user);
        return "登录" + b;
    }

}
